// ============================================================================
//
// Graph framework by Aurelien Moreau aurelien.moreau@gmail.com
// Modified by Pierre CHATEL chatelp@gmail.com
// Distributed under LGPL
// Copyright (C) Aurelien Moreau, 2008, 2009. All rights reserved
//
// ============================================================================

package com.thalesgroup.graphFramework.core.impl;

import java.util.ArrayList;
import java.util.Iterator;

import com.thalesgroup.graphFramework.core.Edge;
import com.thalesgroup.graphFramework.core.Vertex;

import com.thalesgroup.graphFramework.collections.iterator.UnModifiableIterator;

public class VertexImpl<V, E> extends GraphObjectImpl<V, E> implements
		Vertex<V, E> {

	final protected V vertex;

	final protected ArrayList<EdgeImpl<V,E>> ins;
	
	final protected ArrayList<EdgeImpl<V, E>> outs;

	public VertexImpl(final GraphImpl<V, E> graph, int index, final V vertex) {
		super(graph, index);
		this.vertex = vertex;
		this.ins = new ArrayList<EdgeImpl<V, E>>();
		this.outs = new ArrayList<EdgeImpl<V, E>>();
	}

	public VertexImpl(final GraphImpl<V, E> graph, int index) {
		this(graph, index, null);
	}

	public V getVertex() {
		return vertex;
	}

	public Iterator<Edge<V, E>> getIns() {
		return new UnModifiableIterator<Edge<V,E>>(ins.iterator());
	}
	public int getInsSize() {
		return ins.size();
	}

	public Iterator<Edge<V, E>> getOuts() {
		return new UnModifiableIterator<Edge<V,E>>(outs.iterator());
	}
	public int getOutsSize() {
		return outs.size();
	}
}
